#include <iostream>
#include <vector>
using namespace std;
class Solution {
 public:
  vector<int> temp;
  vector<vector<int>> res;
  vector<vector<int>> combinationSum3(int k, int n) {
    backtracking(1, k, n);
    return res;
  }
  void backtracking(int start_index, int k, int n) {
    if (n == 0 && temp.size() == k) {
      res.push_back(temp);
      return;
    }
    int i;
    for (i = start_index; i <= 9 && n - i >= 0; i++) {
      temp.push_back(i);
      backtracking(i + 1, k, n - i);
      temp.pop_back();
    }
  }
};